package com.sk.sourcecircle.adapter;

import android.graphics.Color;
import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sk.sourcecircle.R;
import com.sk.sourcecircle.entity.EventListBean;
import com.sk.sourcecircle.utils.MyUtils;

import java.util.List;

/**
 * Created by sk on 2017/12/28.
 */

public class JonedEventAdapter extends BaseQuickAdapter<EventListBean.DataBean, BaseViewHolder> {

    public JonedEventAdapter(int layoutResId, @Nullable List<EventListBean.DataBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, EventListBean.DataBean item) {
        boolean isNotEnd = false;
        String createTime = item.getCreate_time();
        helper.setText(R.id.event_name, item.getName());

        String applyEndTime = MyUtils.timedate(String.valueOf(item.getApply_end_time()));

        isNotEnd = MyUtils.compareTwoTime("", applyEndTime);

        if (isNotEnd) {
            String leaveTime = MyUtils.getTimeDifference("", applyEndTime);
            helper.setText(R.id.tv_time, MyUtils.getTimeFormatText(createTime) + "   距离结束还有" + leaveTime);
        } else {
            helper.setText(R.id.tv_time, MyUtils.getTimeFormatText(createTime) + "   报名已截止");
        }

        if(Double.parseDouble(item.getMin_price())>0){

            helper.setText(R.id.tv_price,"￥"+item.getMin_price()).setTextColor(R.id.tv_price, Color.parseColor("#ff5050"));

        }else {
            helper.setText(R.id.tv_price,"免费").setTextColor(R.id.tv_price, Color.parseColor("#219021"));

        }

        Glide.with(mContext).load(item.getHead_url()).into((ImageView) helper.getView(R.id.item_bg));
    }
}
